var app = getApp();
Page({
    data:{
        siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
        curPage : "/zofui_sales/kfc/orderlist",
        page : {
            isend : false,
            doing : false,
            doo : 'kfc',
            pdata : {
                op : 'orderlist',
                page : 1,
                isinit : 1,
                otype : 0,
                sortid : 0,
                issort : 1,
            },
            waitf : 0,
            nodataf : 0,
        },
        datalist : [],
		
    },
    onLoad:function(options){
        var self = this;
		var shopid = options.shopid ? options.shopid : '';
        
        var zfid = options.zfid ? options.zfid : '';

        self.setData({
            'page.pdata.isinit' : 1,
            'page.pdata.page' : 1,
            options : options,
            'page.pdata.zfid' : zfid,
            'page.isend' : false,
            'page.doing' : false,
        });
        app.com.auth(function(user){
            app.com.getPage(self,self.data.page,0,function(res){
                var data = res.data.data;

                self.setData({
                    datalist : data.list,
                    params : data.params,
                    sharedata : data.sharedata,
                    sort : data.sort,
                    inited : true,
                    'page.pdata.isinit' : 0,
                });
                
                wx.setNavigationBarTitle({
                    title:  res.data.data.params.title ? res.data.data.params.title : '订单',
                });

            },false,function(res){
                app.com.alert(res.data.message,function(){
                    app.com.backPage(0);
                });
            });
			app.com.setBar(app,self,shopid);
        });
        
    },
    onShareAppMessage : function(e){
        var self = this;
        return {
            title: self.data.sharedata.title,
            path: self.data.sharedata.path,
            imageUrl : '',
        }
    },
    onPullDownRefresh: function () {
        if( this.data.isdown ) return false;
        this.data.isdown = true;
        this.onLoad( this.data.options );
        this.data.isdown = false;

        wx.stopPullDownRefresh();
    },
    showselect(){
        this.setData({
            showselect : !this.data.showselect
        })
    },
    onReachBottom : function(){
        var self = this;
        app.com.getPage(self,self.data.page,20,function(res){
            self.setData({
                datalist : self.data.datalist.concat(res.data.data.list)
            });
        });
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },

})